﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using WPFExcelReport;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TSAV04
    {
       
        public TSAV04()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VABPOS();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e);
         
        }
        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["ABPMANDANT"] = app.Mandant;
            dwData["ABPAUFKRS"] = EXAUF.Substring(0,2);
            dwData["ABPAUFLFD"] = EXAUF.Substring(2, 6);
            dwData["ABPAUFPOS"] = EXAUF.Substring(8, 3);
            SResult = TMV.QABP41(dwData); 
            MergeData(SResult, false, true);
            base.OnEXAUFChg(vlaue);
        }
        
        public override void vwMaster_CurrentChanged(object sender, System.EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            
            if (dwMaster != null)
            {
                KEY = TMV.ABPAUFKRS + TMV.ABPAUFLFD + TMV.ABPAUFPOS + dwMaster["WBBTP"].ToString(); ;
            }
            else
            {
                KEY = "";
            }
        }
    }
}